﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderCrm.aspx.cs" Inherits="qy_54tss_Admin_GpsSet_OrderCrmSuper" %>

<%@ Register Src="CrmTop.ascx" TagName="TogoBanner" TagPrefix="uc1" %>
<%@ Register Src="CRMLeft.ascx" TagName="left" TagPrefix="uc1" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=7" />
    <title>客服系统-<%= WebUtility.GetMyName()%></title>
    <link type="text/css" rel="stylesheet" href="css/indis_style.css?v=1" />
    <link href="../javascript/autocomplete/jquery.autocomplete.css" rel="stylesheet" />
    <link href="../../javascript/jbox/Skins/jbox.css" rel="stylesheet" />


    <script src="../../javascript/jquery-1.3.2.js" type="text/javascript"></script>
    <script src="../../javascript/jCommon.js?V=1" type="text/javascript"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=fMnzyhYs0D1cBEl5iGMQ0Dlg"></script>
    <script src="../javascript/eventwrapper.min.js" type="text/javascript"></script>


    <script type="text/javascript">
        /***** 地图数据 ********/
        var gzoom = 15;
        var isfirst = false;
        var marker = null;
        var ac = null;
        var map = null;
        var myGeo = null;
        var initpoint = null;
        var myIcon = null;
        var issearch = 0; //是否搜索地址，如果是否表示地址加载完成后，开始搜索地址
        var opts = {
            width: 250,     // 信息窗口宽度  
            height: 50    // 信息窗口高度
        }

        var winhtml = " <div><p>确定您的的地图位置后，再输入相关信息点击按钮进行保存</p>";
        winhtml += "<p style=\" float:right; padding-right:10px;\"><input type=\"button\" value=\"确认位置\" onclick='map.closeInfoWindow()' /></p></div>";

        var infoWindow = new BMap.InfoWindow(winhtml, opts);  // 创建信息窗口对象

        var islocal = 0; //1表示已经定位.

        $(document).ready(function () {
            mapinit();
            $(".submit_order_btn").hide();
        })

        function goto_myshop(url) {
            var hasaddress = $("#hidLat").val();
            if (hasaddress == "") {
                alert("此地址未定位，请先定位");
                return false;
            }
            window.location = url;

            return false;
        }
    </script>

    <style type="text/css">
        .hdish_ul .hover {
            background: none repeat scroll 0 0 #72A8DF;
            color: #FFFFFF;
        }

            .hdish_ul .hover .d_name {
                color: #FFFFFF;
            }

        .hdish_ul li:hover {
            background: none repeat scroll 0 0 #72A8DF;
            color: #FFFFFF;
        }

            .hdish_ul li:hover span {
                color: #FFFFFF;
            }

            .hdish_ul li:hover .shopFhandle {
                background: none repeat scroll 0 0 #4784C1;
            }

        .hdish_ul li .shopFhandle {
            color: #FFFFFF;
            font-size: 24px;
            height: 29px;
            left: 0;
            line-height: 29px;
            position: absolute;
            text-align: center;
            top: 0;
            font-weight: bold;
            width: 30px;
        }
    </style>

</head>
<body>
    <form runat="server">
        <asp:HiddenField runat="server" ID="hidLat" />
        <asp:HiddenField runat="server" ID="hidLng" />
        <asp:HiddenField runat="server" ID="hidUid" Value="-2" />
        <asp:HiddenField runat="server" ID="hfcityname" />
        <asp:HiddenField runat="server" ID="hfcityid" />


        <asp:HiddenField runat="server" ID="hidTogoId" Value="0" />
        <asp:HiddenField runat="server" ID="hidTogoName" />



        <asp:HiddenField runat="server" ID="hfsqlwhere" Value="" />


        <div class="wrap">
            <uc1:TogoBanner runat="server" ID="Banner" />
            <div class="infaq_con">
                <uc1:left runat="server" ID="left" />
                <div class="indis_right" style="position: relative; min-height: 500px;">

                    <div class="indis_right_top" id="shopdiv">
                        <div class="infaq_list_title">
                            <div class="infaq_list_left">

                                <div style="padding-top: 20px; vertical-align: top;">

                                    <div>
                                        <span style="line-height: 50px; vertical-align: top; height: 50px">备注：</span><textarea id="tbremark" placeholder="请输入备注信息" style="padding: 10px; width: 300px;"></textarea>
                                    </div>
                                </div>

                                <div style="margin-bottom: 10px; margin-top: 10px;">
                                    热门：


                                    <asp:Repeater runat="server" ID="rpthot">
                                        <ItemTemplate>
                                            <a href="javascript:" onclick="seletedshop(<%# Eval("unid") %>,'<%# Eval("name") %>','<%# Eval("lat") %>','<%# Eval("lng") %>')"><%# Eval("name") %></a>
                                        </ItemTemplate>
                                    </asp:Repeater>


                                </div>


                                <div style="margin-bottom: 10px; margin-top: 10px;">
                                    商家：<input name="" type="text" runat="server" id="tbshopname" placeholder="" class="infaq_list_text" style="width: 300px;" />

                                    <span style="color: blue; display: none;" id="shopnotice">已经选择商家</span> <span>请输入商家名称或者拼音首字母，并下接选择</span>
                                </div>
                            </div>
                        </div>



                    </div>

                    <div class="" style="border-top: 2px solid #008ada; display: none;" id="foodcontainer">
                        <div>
                            <table style="width: 96%; margin: 20px; padding: 0;" cellpadding="0" cellspacing="0"
                                class="order_table infaq_infor foodtable" id="myfoodtable">

                                <tr id="food_row_0" class="fooditem">

                                    <td>商品：<input type="text" id="tbfoodname" class="j_text foodbox" style="width: 260px;" reg="\S"
                                        rownum="0" tip="请输入商品名称" />
                                    </td>
                                    <td style="width: 60%">数据：<input type="text" id="tbnum" class="j_text" style="width: 60px;" reg="^\d+$" tip="数量格式错误,请输入整数" />
                                        <input type="button" value="快速添加" onclick="fastadd(0)" />
                                    </td>


                                </tr>
                            </table>
                        </div>


                        <div class="dish_type_unit" id="searchfood">
                        </div>




                    </div>






                </div>


                <div style="display: none;" id="mapdiv">


                    <div class="indis_right_top">
                        <div style="padding-left: 20px; margin: 10px;">
                            <a class="infaq_address_sure_btn" href="javascript:hide_map()" style="float: right; padding-right: 10px;">关闭地图</a>
                            <div class="mynotice">
                                提示：拖动标准修改用户的位置
                            </div>
                        </div>

                        <div id="map_canvas" style="width: 100%; height: 400px">
                        </div>

                    </div>
                </div>


            </div>
        </div>
    </form>


    <script id="foodTemplate" type="text/x-jsrender">
        {{for #data}}

           <div class="sortitem_{{:SortID}} sortitem">
               <div class="disy_type_title ">
                   <span class="more"><a href="#j_s_0">回到顶部</a></span>
                   {{:SortName}}
               </div>

               <ul class="hdish_ul">
                   {{for Foodlist ~parentIndex=#index ~parentName=name}}
           
                 

                   
                    <li id="foodid_{{:Unid}}" style="cursor: pointer; padding-left: 40px;" class="food_items" onclick="AddToShoppingCart('{{:Unid}}','{{:FoodName}}','{{:FPrice}}',1);"><span class="shopFhandle">+</span>

                        <span class="price">￥{{:FPrice}}</span><span title="{{:FoodName}}">{{:FoodName}}</span> </li>


                   {{/for}}


                          

               </ul>
               <div class="clear">
               </div>
           </div>



        <li style="width: 200px;"><a href="{{:url}}" class="myadd">{{:label}}</a></li>
        {{/for}}
                    
    </script>


</body>
</html>



<script src="javascript/map.js?v=112" type="text/javascript"></script>
<script src="../javascript/autocomplete/jquery.autocomplete.js?v=0517"></script>
<script src="../../javascript/jbox/jquery.jBox-2.3.min.js"></script>
<script src="../../javascript/jsrender.js"></script>

<script type="text/javascript">
    function seletedshop(shopid, name, lat, lng)
    {
        var $input = $("#tbshopname");
        $input.attr("shopid", shopid);
        $input.attr("lat", lat);
        $input.attr("lng", lng);

        $input.addClass("system_shop");
        $("#shopnotice").show();
        $("#foodcontainer").show();
        $input.val(name);
        var searchshopurl = "/ajaxHandler.ashx?method=autosearchfood&t=" + Math.random(1) + "&tid=" + shopid;
        $("#tbfoodname").autocomplete(searchshopurl);
        $("#hidTogoId").val(shopid);
        $("#hidTogoName").val(name);

        //获取商品
        loadfood(shopid);
    }

</script>

<script type="text/javascript">
    //点击获取用户地址
    function getmyaddress() {


        var tel = $("#left_tbtel").val();
        if (tel == "") {
            alert("请输入电话");
            return;
        }

        var url = "ajax/getaddressByTel.aspx";
        var para = "Tel=" + tel;
        jQuery.ajax(
        {
            type: "post",
            url: url,
            data: para,
            success: function (msg) {
                $(".myadd_ul").html(msg);
                setfirstaddr();

            }
        })
    }

    var searchshopurl = "/ajaxHandler.ashx?method=autosearchshop&t=" + Math.random(1) + "&cid=" + $("#hfcityid").val();
    $("#tbshopname").autocomplete(searchshopurl);


    $(document).ready(function () {
        boxinit();
    })

    function boxinit() {
        $("#tbshopname").keydown(function (e) {
            var ee = e ? e : window.event ? event : null;
            var keyNum = ee.keyCode == 0 ? ee.which : ee.keyCode;
            if (keyNum == 8) {
                //如果是删除键,要删除相关参数;
                $(this).attr("shopid", "0");
                $(this).attr("sid", "0");
                $(this).attr("lat", "0");
                $(this).attr("lng", "0");
                $(this).attr("tel", "0");
                $(this).attr("grade", "0");
                $(this).removeClass("system_shop");
                $("#shopnotice").hide();
                $("#foodcontainer").hide();

                preshopdata = null;
            }

        });
    }


    function loadfood(tid) {
        jQuery.ajax(
        {
            type: "post",
            url: "/ajaxHandler.ashx",
            data: "method=searchfoodByTid&tid=" + tid + "&t=" + new Date().getTime(),
            dataType: "json",
            success: function (msg) {

                $("#searchfood").html($("#foodTemplate").render(msg));
                ListCart();
                $(".submit_order_btn").show();
            }
        })
    }


    function CheckCart() {

        if ($(".myshop").length <= 0) {
            alert('你的餐盒是空的,不的提交!');
            return false;
        }


        var tel = $("#left_tbtel").val();
        if (tel == "") {
            alert("请输入电话");
            return;
        }

        if ($(".radio1").length <= 0) {
            alert('请先添加地址，再提交订单');
            return false;
        }


        var hidLat = $("#hidLat").val();
        var hidLng = $("#hidLng").val();
        if (hidLat == "") {
            alert("请点击搜索，添加地址");
            return;
        }
        var togoid = $D("hidTogoId").value;

        var tbremark = $("#tbremark").val();
        handlecookie("remark", encodeURI(tbremark), { expires: 1, path: "/", secure: false });

        var title = "提交订单";
        $.jBox("iframe:submitorderbox.aspx?id=" + togoid + "&tel=" + tel, {
            title: title,
            width: 900,
            height: 550,
            buttons: {}
        });

    }

    //客服一键发单
    function fastaddorder()
    {
        var tel = $("#left_tbtel").val();
        var title = "客服一键发单";
        $.jBox("iframe:fastaddorderbox.aspx?id=" + 0 + "&tel=" + tel, {
            title: title,
            width: 900,
            height: 550,
            buttons: {}
        });

    }
</script>
